From: Doug Goldstein Date: Wed, 16 Mar 2016 14:11:00 +0000 (-0500) Subject: tmem: drop direct usage of opt_tmem X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~1542 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22man:///%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22man:/?a=commitdiff_plain;h=6cddfb4ef6ff012d867592fb9e060f07ad5a20b2;p=xen.git tmem: drop direct usage of opt_tmem Most callers of tmem_freeable_pages() checked to see if by checking opt_tmem before calling tmem_freeable_pages() but not all of them did. This seemed like an oversight and to avoid similar situations like that, stick the check of tmem into tmem_freeable_pages(). Similarly other places should not directly check opt_tmem but instead use the tmem_enabled() helper function. Signed-off-by: Doug Goldstein Acked-by: Jan Beulich Signed-off-by: Konrad Rzeszutek Wilk --- diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 50119303ac..c5c332ddde 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1272,7 +1272,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) init_domheap_pages(s, e); } - if ( opt_tmem ) + if ( tmem_enabled() ) { printk(XENLOG_WARNING "TMEM physical RAM limit exceeded, disabling TMEM\n"); diff --git a/xen/common/memory.c b/xen/common/memory.c index ef57219eac..c7fca96e30 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -202,7 +202,7 @@ static void populate_physmap(struct memop_args *a) if ( unlikely(!page) ) { - if ( !opt_tmem || a->extent_order ) + if ( !tmem_enabled() || a->extent_order ) gdprintk(XENLOG_INFO, "Could not allocate order=%u extent: id=%d memflags=%#x (%u of %u)\n", a->extent_order, d->domain_id, a->memflags, diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 22e8feb34c..98e30e58a7 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -652,7 +652,7 @@ static void __init setup_low_mem_virq(void) static void check_low_mem_virq(void) { unsigned long avail_pages = total_avail_pages + - (opt_tmem ? tmem_freeable_pages() : 0) - outstanding_claims; + tmem_freeable_pages() - outstanding_claims; if ( unlikely(avail_pages <= low_mem_virq_th) ) { @@ -738,7 +738,7 @@ static struct page_info *alloc_heap_pages( * Others try tmem pools then fail. This is a workaround until all * post-dom0-creation-multi-page allocations can be eliminated. */ - if ( opt_tmem && ((order == 0) || (order >= 9)) && + if ( ((order == 0) || (order >= 9)) && (total_avail_pages <= midsize_alloc_zone_pages) && tmem_freeable_pages() ) goto try_tmem; @@ -984,7 +984,7 @@ static void free_heap_pages( avail[node][zone] += 1 << order; total_avail_pages += 1 << order; - if ( opt_tmem ) + if ( tmem_enabled() ) midsize_alloc_zone_pages = max( midsize_alloc_zone_pages, total_avail_pages / MIDSIZE_ALLOC_FRAC); @@ -1755,7 +1755,7 @@ int assign_pages( { if ( unlikely((d->tot_pages + (1 << order)) > d->max_pages) ) { - if ( !opt_tmem || order != 0 || d->tot_pages != d->max_pages ) + if ( !tmem_enabled() || order != 0 || d->tot_pages != d->max_pages ) gprintk(XENLOG_INFO, "Over-allocation for domain %u: " "%u > %u\n", d->domain_id, d->tot_pages + (1 << order), d->max_pages); diff --git a/xen/common/tmem.c b/xen/common/tmem.c index 0436e49291..16e249ae4c 100644 --- a/xen/common/tmem.c +++ b/xen/common/tmem.c @@ -2837,6 +2837,9 @@ void *tmem_relinquish_pages(unsigned int order, unsigned int memflags) unsigned long tmem_freeable_pages(void) { + if ( !tmem_enabled() ) + return 0; + return tmem_page_list_pages + _atomic_read(freeable_page_count); }